<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>用户注册信息</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
<div class="wrapper" style="width: 900px;margin-top: 40px">
    <fieldset class="layui-elem-field layui-field-title">
        <legend style="font-size: 26px">注册用户</legend>
    </fieldset>
    <form id="addUserForm" class="layui-form">

        <div class="layui-form-item">
            <label class="layui-form-label">用户账号</label>
            <div class="layui-input-block">
                <input type="text" name="account" required lay-verify="required" placeholder=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户密码</label>
            <div class="layui-input-block">
                <input type="text" name="password" required lay-verify="required" placeholder=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">联系电话</label>
            <div class="layui-input-block">
                <input type="text" name="tel" required lay-verify="required|phone" placeholder=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">用户昵称</label>
            <div class="layui-input-block">
                <input type="text" name="username" required lay-verify="required" placeholder=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <hr>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="addUserRecord" id="addUserRecord-btn">保存</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</div>
<script src="/static/layui/layui.js"></script>
<script>
    layui.use(['element','form','layer','upload'],function () {
        var element = layui.element,
            form = layui.form ,
            layer = layui.layer,
            upload = layui.upload,
            $ = layui.jquery;

        form.on("submit(addUserRecord)",function(data){
            $.post("/rent/user/addUserRecord",$("#addUserForm").serialize(),function(res){
                if(res==="OK"){
                    layer.msg("用户注册成功！",{icon:1,end:function(){window.location.href="/rent/user/toIndex";}});
                    $("#addUserForm")[0].reset();
                }
                if (res==="FAIL"){
                    layer.msg("用户注册失败，账号可能重复");
                }
            });
            return false;
        });
    });
</script>
</body>
</html>